package com.pkx.cloud.fse7.dms.deviceread.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.pkx.cloud.fse7.dms.deviceread.entity.DeviceRead;
import com.pkx.cloud.fse7.dms.deviceread.repo.DeviceReadMapper;
import com.pkx.cloud.fse7.dms.deviceread.service.DeviceReadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;
import java.util.Set;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
 * 门禁控制器子设备 服务实现类
 *
 * @author ly
 * @since 2020-10-14
 */
@Service
@DS("master")
public class DeviceReadServiceImpl extends ServiceImpl<DeviceReadMapper, DeviceRead> implements DeviceReadService {

    /**
     * 分页列表
     *
     * @param deviceRead
     * @return
     */
    @Override
    public Page<DeviceRead> pageList(Page page, DeviceRead deviceRead) {
        LambdaQueryWrapper<DeviceRead> lambdaQueryWrapper = Wrappers.lambdaQuery(DeviceRead.class);
        return page(page, lambdaQueryWrapper);
    }

    /**
     * 列表查询
     *
     * @param deviceRead
     * @return
     */
    @Override
    public List<DeviceRead> listByEntity(DeviceRead deviceRead) {
        LambdaQueryWrapper<DeviceRead> lambdaQueryWrapper = Wrappers.lambdaQuery(DeviceRead.class);
        return list(lambdaQueryWrapper);
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public DeviceRead selectById(Long id) {
        return getById(id);
    }

    @Override
    public List<DeviceRead> getAll() {
        return baseMapper.getALl();
    }

    @Override
    public List<DeviceRead> getByRids(Set<String> ids) {
        return lambdaQuery().in(DeviceRead::getRid, ids).list();
    }

    @Override
    public List<DeviceRead> getDmsDevice(List<String> list) {
        return baseMapper.getDmsDevice(list);
    }

    public String getByReadId(String id) {
        return baseMapper.getByReadId(id);
    }
}

